package com.miplus.ccrm.core.controller;

import com.alibaba.fastjson2.JSONObject;
import com.miplus.ccrm.common.*;
import com.miplus.ccrm.core.controller.vo.dos.Cafp0001ResultReqVo;
import com.miplus.ccrm.core.controller.vo.dos.NITS0016ResultReqVo;
import com.miplus.ccrm.core.service.aicall.ObCallCaseService;
import com.miplus.ccrm.core.service.cust.FiCustomerScorecardService;
import com.miplus.ccrm.core.utils.SpringContextUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 2-12. 外部接口
 */
@CrossOrigin(origins = "*", maxAge = 3600)
@RestController
@RequestMapping("/do")
@Slf4j
public class DoController {

    @Resource
    private ObCallCaseService obCallCaseService;

    @Resource
    private FiCustomerScorecardService customerScorecardService;

    /**
     * AiCall返回结果
     */
    @PostMapping("/aiCallResult")
    public AI94R<Ai94ResVo> aiCallResult(@RequestBody @Validated String respval){

        log.info("respval:{}",respval);
//      String timestamp= SpringContextUtil.getRequestValue("timestamp");
        return AI94R.SuccessBody(obCallCaseService.aiCallResult(respval,null));
    }

    /**
     * 授信反欺诈(申请)回调
     */
    @PostMapping("/cafp0001Result")
    public ESCR<EscResVo> cafp0001Result(@RequestBody @Validated String respval){

        log.info("cafp0001Result1{}:"+respval);
        return ESCR.SuccessBody(customerScorecardService.cafp0001ResultHandle(JSONObject.parseObject(respval)));
    }

    /**
     * 新综合柜面 收费/付费 接口回调
     * @param reqVo
     * @return
     */
    @PostMapping("/nits0016Result")
    public R<CmdResVo> nits0016Result(@RequestBody @Validated NITS0016ResultReqVo reqVo){
        System.out.println("reqVo:"+reqVo);

        return R.Success(new CmdResVo(1,"ok"));
    }
}
